/*
    自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
    要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
    们也能够保持自己的本色走下去。
    To the world , you will be a person , but to a person , you
    will be the world .                               ——AKPower
    */
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
queue<ll> p;
vector<ll> v;

int main()
{
    IOS;
    ll t, n;
    while (cin >> t)
    {
        while (t--)
        {
            cin >> n;
            v.clear();
            for (ll i = 1; i <= n; i++)
            {
                v.push_back(i);
            }
            ll len = v.size();
            ll ch = 2;
            while (len > 3)
            {
                ll cnt = 0;
                for (ll i = 0; i < len; i++)
                {
                    if ((i + 1) % ch > 0)
                    {
                        p.push(v[i]);
                    }
                }
                len = 0;
                v.clear();
                while (!p.empty())
                {
                    v.push_back(p.front());
                    p.pop();
                }
                ch = 5 - ch;
                len = v.size();
            }
            cout << v[0];
            for (ll i = 1; i < len; i++)
            {
                cout << " " << v[i];
            }
            cout << endl;
        }
    }
    getchar();
    getchar();
    return 0;
}
